#include <bits/stdc++.h>
using namespace std;
int n,m;
int a[100005];
int c[100005];
random_device rd;
mt19937 rng(rd());

int main(){
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=m;i++) cin>>c[i];
    int k=0;
    int pw=2;
    do{
        pw*=2;
        k++;
    }while(pw<n);
    for(int i=1;i<=pw-n;i++) cin>>k;
    int t;
    cin>>t;
    while(t--){
        cout<<rng()%pw<<'\n';
    }
    return 0;
}